﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGiBitonalRasterTransformer : OdGiRasterImageWrapper
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGiBitonalRasterTransformer(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGiBitonalRasterTransformer_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGiBitonalRasterTransformer obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGiBitonalRasterTransformer()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGiBitonalRasterTransformer(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public void setOriginal(OdGiRasterImage pOrig, uint foregroundColor, uint backgroundColor, bool transparent)
		{
			GlobalsPINVOKE.OdGiBitonalRasterTransformer_setOriginal(this.swigCPtr, OdGiRasterImage.getCPtr(pOrig), foregroundColor, backgroundColor, transparent);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual uint numColors()
		{
			uint result = GlobalsPINVOKE.OdGiBitonalRasterTransformer_numColors(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual uint color(uint colorIndex)
		{
			uint result = GlobalsPINVOKE.OdGiBitonalRasterTransformer_color(this.swigCPtr, colorIndex);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual uint paletteDataSize()
		{
			uint result = GlobalsPINVOKE.OdGiBitonalRasterTransformer_paletteDataSize(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void paletteData(byte[] bytes)
		{
			GlobalsPINVOKE.OdGiBitonalRasterTransformer_paletteData(this.swigCPtr, Teigha.Core.Helpers.MarshalbyteFixedArray(bytes));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual OdGiRasterImage.PixelFormatInfo pixelFormat()
		{
			OdGiRasterImage.PixelFormatInfo result = new OdGiRasterImage.PixelFormatInfo(GlobalsPINVOKE.OdGiBitonalRasterTransformer_pixelFormat(this.swigCPtr), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual int transparentColor()
		{
			int result = GlobalsPINVOKE.OdGiBitonalRasterTransformer_transparentColor(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject clone()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiBitonalRasterTransformer_clone(this.swigCPtr);
			OdRxObject result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void copyFrom(OdRxObject pSource)
		{
			GlobalsPINVOKE.OdGiBitonalRasterTransformer_copyFrom(this.swigCPtr, OdRxObject.getCPtr(pSource));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
